<template>
    <el-button :type="type" @click="goBack">{{text}}</el-button>
</template>
<script lang="ts" name="btn-back" setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const props = withDefaults(
  defineProps<{
    type?: string;
    text?: string;
    back?:number | string;
  }>(),
  {
    type: "",
    text: "返回",
    back:-1
  }
);

const goBack = () => {
    if(props.back){
      router.go(Number(props.back));
    }else{
      router.back();
    }
}
</script>
